<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>MyOperation</title>
<script src="../static/js/jquery.min.js"></script>
<script>
$(document).ready(function() {
	$("#opForm").submit(function() {

		$("#op1").prop("disabled", true);
		$("#op2").prop("disabled", true);
		$("#submitButton").prop("disabled", true);
		
		var postData = {
			operand1: $("#op1").val(),
			operand2: $("#op2").val()
		};
		$.ajax({
			method: "POST",
			url: "MyOperation",
			contentType : "application/json",
			data: JSON.stringify(postData),
			dataType : "json",
			success: function(data) {
				if (data.status == 0) {
					alert(data.result);
				}
			},
			error: function() {
				alert("服务器连接失败！");
			},
			complete: function() {
				$("#op1").prop("disabled", false);
				$("#op2").prop("disabled", false);
				$("#submitButton").prop("disabled", false);
			}
		});
		
		return false;
	});
});
</script>
</head>
<body>

<form id="opForm">
  <input type="text" id="op1" />
  <input type="text" id="op2" />
  <input type="submit" id="submitButton" value="提交">
</form>

</body>
</html>